package com.woniuxy.dr_mall.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniuxy.dr_mall.entity.DrRegion;
import com.woniuxy.dr_mall.provider.DrRegionProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 张哲轩
 * @since 2021-08-11
 */
public interface DrRegionMapper extends BaseMapper<DrRegion> {

    @Select("select * from dr_region where pid = #{pid}")
    List<DrRegion> getByPid(@Param("pid") Integer pid);

    @Select("select * from dr_region where pid = '0'")
    List<DrRegion> getPidIsNull();

    //通过父pid进行数据的查询
    @SelectProvider(type= DrRegionProvider.class,method = "usePidSelect")
    List<DrRegion> usePidSelect(int pid);



    @Select("select * from dr_region where id = #{id}")
    DrRegion getById(@Param("id") Integer id);

    @Select("select * from dr_region where name = #{name}")
    DrRegion getIdByName(@Param("name")String name);
}
